package com.example.administrator.zhongyichou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.zhongyichou.help.ImageLoader;
import com.example.administrator.zhongyichou.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lichenyu on 2017/11/24.
 * 描述：
 */

public class PublicityDetailsAdapter extends ListBaseAdapter {
    public PublicityDetailsAdapter(Context mContext, List list) {
        super(mContext, list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.publicity_details_item, null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        ImageLoader.centerCropUrl(getContext(), (String) getItem(position),holder.img);
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.img)
        ImageView img;
        @BindView(R.id.txt)
        TextView txt;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
